<template>
    <div class="card">
        <!-- {{this.cardData}} -->
        <div class="block">
            <div v-if="this.cardData == ''" class="noEquipment"> 
                该项绑定设备未开启
            </div>
            <el-carousel trigger="click" class="card_hight" :autoplay="false" :initial-index="cardData.index" >
            <el-carousel-item v-for="item in cardData.unit" :key="item.index">
                <!-- 设备标题 -->
                <router-link to="/overview">
                    <h4 class="normal" @click="router('disinfect',item)" :title="item.name">
                    <img class="title_icon" src="../../assets/title.png" alt />
                    {{item.typename}}:&nbsp;{{item.name}}
                 </h4>
                </router-link>

                <!-- 卡片内容 -->
                <div class="card_padding">
                    <div class="dis_top">
                        <div class="dis_left">
                            <div class="dis_title">左舱</div>
                            <div class="dis_pross">
                                <div class="airclean_progress">
                                    <p  class="airclean_progress_name">{{item.unit[0].name}}:
                                    </p>
                                    <el-progress :show-text="false" :percentage="parseInt((item.unit[0].value/(item.unit[0].max-item.unit[0].min))*100 >= 100 ? 100 : (item.unit[0].value/(item.unit[0].max-item.unit[0].min))*100) || 0" :stroke-width="10" ></el-progress>
                                    <p class="airclean_progress_val">{{item.unit[0].value.toFixed(0)}}
                                        <span>{{item.unit[0].flag}}</span>
                                    </p>
                                </div>
                                <div class="airclean_progress">
                                    <p  class="airclean_progress_name">{{item.unit[1].name}}:
                                    </p>
                                    <el-progress :show-text="false" :percentage="parseInt((item.unit[1].value/(item.unit[1].max-item.unit[1].min))*100 >= 100 ? 100 : (item.unit[1].value/(item.unit[1].max-item.unit[1].min))*100) || 0" :stroke-width="10" ></el-progress>
                                    <p class="airclean_progress_val">{{item.unit[1].value.toFixed(0)}}
                                        <span>{{item.unit[1].flag}}</span>
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="dis_right">
                            <div class="dis_title">右舱</div>
                            <div class="dis_pross">
                                <div class="airclean_progress">
                                    <p  class="airclean_progress_name">{{item.unit[2].name}}:
                                    </p>
                                    <el-progress :show-text="false" :percentage="parseInt((item.unit[2].value/(item.unit[2].max-item.unit[2].min))*100 >= 100 ? 100 : (item.unit[2].value/(item.unit[2].max-item.unit[2].min))*100) || 0" :stroke-width="10" ></el-progress>
                                    <p class="airclean_progress_val">{{item.unit[2].value.toFixed(0)}}
                                        <span>{{item.unit[2].flag}}</span>
                                    </p>
                                </div>
                                <div class="airclean_progress">
                                    <p  class="airclean_progress_name">{{item.unit[3].name}}:
                                    </p>
                                    <el-progress :show-text="false" :percentage="parseInt((item.unit[3].value/(item.unit[3].max-item.unit[3].min))*100 >= 100 ? 100 : (item.unit[3].value/(item.unit[3].max-item.unit[3].min))*100) || 0" :stroke-width="10" ></el-progress>
                                    <p class="airclean_progress_val">{{item.unit[3].value.toFixed(0)}}
                                        <span>{{item.unit[3].flag}}</span>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="dis_bottom">
                        <div class="dis_state">
                            <div class="dis_line"></div>
                            <div class="dis_mode">
                                <span class="dis_mode_blue" v-if="item.unit[4].value == 0">低速</span>
                                <span class="dis_mode_blue" v-if="item.unit[4].value == 1">高速</span>
                            </div>
                            <div>风速</div>
                        </div>
                        <div class="dis_state">
                            <div class="dis_line"></div>
                            <div class="dis_mode">
                                <span v-if="item.unit[5].value == 0">关机</span>
                                <span class="dis_mode_blue" v-if="item.unit[5].value == 1">快速净化</span>
                                <span class="dis_mode_blue" v-if="item.unit[5].value == 2">高效净化</span>
                            </div>
                            <div>工作模式</div>
                        </div>
                        <div class="dis_state">
                            <div class="dis_mode">
                                <span v-if="item.unit[6].value == 0">关闭</span>
                                <span class="dis_mode_blue" v-if="item.unit[6].value == 1">开启</span>
                            </div>
                            <div>照明</div>
                        </div>
                    </div>
                </div>
                 
            </el-carousel-item>
            </el-carousel>
        </div>
        
    </div>
</template>

<script>
export default {
    props: ['nowIndex', 'cardData', 'nowId'],
    data () {
        return{
        }
    },
    created() {
        // this.getCardData();
        // // 从缓存获取数据定时器
        // this.timergetCardData = setInterval(() => {
        // setTimeout(this.getCardData(), 0);
        // }, this.$store.state.requestTime);
    },
    methods: {
        // 跳转
        router(val,item){
            var arr = {
                addr:item.addr,
                name:item.name,
                type:item.type,
                uid:item.uid
            }
            localStorage.setItem("当前设备编号", JSON.stringify(arr))
            localStorage.setItem("menuRouter", val)
        },
    },
     // 清除定时器
    beforeDestroy() {
        // alert("已经销毁了")
    },
}
</script>

<style scoped>

/deep/ .el-carousel__container .el-carousel__arrow {
    height: 150px !important;
    width: 110px !important;
    border-radius: 0;
    background: none;
}
/deep/ .el-icon-arrow-left {
    margin-left: -110px !important;
}
/deep/ .el-icon-arrow-right{
    margin-right: -110px !important;
}
/deep/ .el-carousel__indicators{
    display: none;
}
.normal .card_icon{
    font-size: 20px;
}
/deep/ .card_padding {
    padding: 0px 20px 0px 30px !important;
}
.dis_top{
    width: 100%;
    height: 140px;
}
.dis_left{
    display: flex;
    height: 65px;
    border-left: 1px solid #79b6f6;
    background: linear-gradient(to left , rgba(255, 0, 0, 0), #60b4fda3,#60b4fda3 500%);
    margin-bottom: 10px;
}
.dis_title{
    width: 80px;
    text-align: center;
    height: 70px;
    line-height: 70px;
}
.dis_pross{
    padding-top: 8px;
}
/* 进度条 */
.airclean_progress{
    display: flex;
    margin-bottom: 12px;
}
.airclean_progress:first-child{
    margin-top: 5px;
}
.airclean_progress_name{
    width: 60px;
    overflow: hidden;
    line-height: 18px;
    position: relative;
    top: -3px;
}
/* .airclean_progress_val span{
    color: #acacac;
    font-size: 12px;
} */
.airclean_progress_val{
    width: 85px;
    overflow: hidden;
    line-height: 20px;
    color: #38bdea;
    font-size: 15px;
    white-space:nowrap
}
.airclean_progress_val span{
    font-size: 13px;
}
/deep/ .el-progress-bar__inner{
 background-color: transparent !important;
 background-image: linear-gradient(to right,#38bdea,#a8d5f6d9);
    background-size: 100% 100%;}
/deep/ .progress_title {
    /* display: inline-block; */
    width: 130px;
    line-height: 24px;
    float: left;
    /* flex: 1; */
    font-size: 16px;

}
/deep/ .el-progress{
    padding: 4px 0;
    padding-right: 10px;
    width: 195px;
    /* flex: 1; */
}
/deep/ .el-progress-bar__outer{
    background: none;
    border: .5px solid rgba(89, 129, 165, 0.8);
}
.dis_right{
    display: flex;
    height: 65px;
    border-left: 1px solid #79b6f6;
    background: linear-gradient(to left , rgba(255, 0, 0, 0), #60b4fda3,#60b4fda3 500%);
}
.dis_bottom{
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dis_state{
    width: 135px;
    height: 100%;
    text-align: center;
    position: relative;
}
.dis_line{
    position: absolute;
    width: 3px;
    height: 30px;
    background: #facd86;
    right: 0px;
    top: 30px;
}
.dis_mode{
    height: 50px;
    line-height: 50px;
    font-size: 18px;
    color: #bbbbbb;
}
.dis_mode_blue{
    color: #38bdea;
}
</style>